import java.util.Arrays;

public class CuttingRope {

    public static void main(String[] args) {
        CuttingRope cuttingRope = new CuttingRope();
        System.out.println(cuttingRope.cuttingRope(10));
    }

    public int cuttingRope(int n) {
        int[][] dp = new int[n][n + 1];
        Arrays.fill(dp[1], 1);
        for (int i = 2; i < n; i++) {
            for (int j = 0; j < n + 1; j++) {
                dp[i][j] = dp[i - 1][j];
                if (j - i >= 0) {
                    dp[i][j] = Math.max(dp[i][j], dp[i][j - i] * i);
                }
            }
        }
        return dp[n - 1][n];
    }

    public int cuttingRope2(int n) {
        int[] dp = new int[n + 1];
        for (int i = 2; i < n + 1; i++) {
            for (int j = 0; j < i; j++) {
                dp[i] = Math.max(Math.max((i - j) * j, dp[i - j] * j), dp[i]);
            }
        }
        return dp[n];
    }
}
